package protocol

import "goAdapter/device/commInterface"

const (
	NodeAccessReadOnly int = iota
	NodeAccessReadWrite
)

type NodeProperty struct {
	ID         string //属性名称，只可以是字母和数字的组合
	RegType    string //寄存器类型
	RegAddr    int    //寄存器地址
	AccessMode int    //读写属性
	DataType   string //类型 uint32 int32 double string
	Value      interface{}
	SetValue   interface{}
}

type ProInterface interface {
	Construct() //构造方法
	Init(inf commInterface.CommunicationInterface) bool
	GetNode(node *NodeProperty) int
	SetNode(node *NodeProperty) int
	//GetUseComIf() bool
	GetComInf() commInterface.CommunicationInterface
	Connect() bool
	IsConnect() bool
	SetSid(id int)
	GetSid() int
	GetName() string
}

//const (
//	CommTypeIoIn      int = 0
//	CommTypeIoOut     int = 1
//	CommTypeSerial    int = 2
//	CommTypeTcpClient int = 3
//	CommTypeTcpServer int = 4
//)

// 通信协议
//var ProInterfaceMap = make(map[string]ProInterface, 0)
//
//func ProInterfaceInit() {
//	ProModbusTcp.Construct()
//	ProInterfaceMap[ProModbusTcp.Name] = &ProModbusTcp
//}

func GetProInterface(proName string) ProInterface {
	if proName == "modbusTCP" {
		return new(ProModbusTcpTemplate)
	} else if proName == "haasTCP" {
		return new(ProHaasTcpTemplate)
	}

	return nil
}
